#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/BoxComponent.h"

#include "Study/Lib/Lib.h"
#include "MainCharacter.h"

#include "Servant.generated.h"

UCLASS()
class STUDY_API AServant : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AServant();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	// Called every frame
	virtual void Tick(float DeltaTime) override;

private:

	UPROPERTY(EditAnywhere)
	UStaticMeshComponent* StaticMeshComponent;

	UPROPERTY(EditAnywhere)
	UBoxComponent* BoxComponent;

	UPROPERTY(EditAnywhere)
	ULib* Lib;

	UFUNCTION()
	void StepIn(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) {
		
		AMainCharacter* Main = Cast<AMainCharacter>(OtherActor);
		
		if (Main) {
			Main->GetHUD()->SetApproachText("[F]");
			Main->SetCouldOpenPickTribute(true);
		}

		ULib::Echo(TEXT("StepIn"));
		ULib::Echo(TEXT("StepIn"), false);
	}

	UFUNCTION()
	void StepOut(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex) {
		
		AMainCharacter* Main = Cast<AMainCharacter>(OtherActor);

		if (Main) {
			Main->GetHUD()->SetApproachText("");
			Main->SetCouldOpenPickTribute(false);
		}
	}
};
